package com.tedu._04mybatis.mapper;

import com.tedu._04mybatis.pojo.Comment;
import com.tedu._04mybatis.pojo.CommentVo1;
import com.tedu._04mybatis.pojo.CommentVo2;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    //@Insert("INSERT INTO comment(content,created,weibo_id,user_id) VALUES (#{content},#{created},#{weiboId},#{userId})")
    int insert(Comment comment);

    //@Delete("DELETE FROM comment WHERE id=#{id}")
    int deleteById(Integer id);

    //@Update("UPDATE comment SET content=#{content},created=#{created},weibo_id=#{weiboId},user_id=#{userId} WHERE id=#{id}")
    int updateById(Comment comment);

//    @Select("SELECT content,user_id userId " +
//            "FROM comment " +
//            "WHERE id=#{id}")
    CommentVo1 selectCommentById(Integer id);

//    @Select("SELECT id,content,user_id userId " +
//            "FROM comment " +
//            "WHERE user_id=#{id}")
    List<CommentVo2> selectCommentByUserId(Integer id);
    int dynamicUpdate(Comment comment);
    //同时删除多条字段的方法
    int dynamicDeleteComment(Integer[] ids);
    //用集合的方法来进行字段的删除
    int dynamicDeleteComment2(List<Integer> ids);

}

